<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/config.inc.php');
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/top.inc.php');
?>
<?php
$instructor_id = mysql_real_escape_string(strip_tags($_GET['id']));
$q = "SELECT * FROM instructors WHERE id = '$instructor_id'";
$r = mysql_query($q);
$row = mysql_fetch_assoc($r);
$instructor_fname = $row['first_name'];
$instructor_lname = $row['last_name'];
?>
<p>
	<a href="index.php">&lt;&lt; Back to Instructors Portal</a><br />
</p>
<?php
echo "<h1>$instructor_fname $instructor_lname Timeslot Preference</h1>";
echo "<p><b>Please select building to view timeslots:</b></p>";

//select statement
$query="SELECT * FROM buildings";
$result=mysql_query($query);


//determine dynamically number of rows read from table
$num_rows=mysql_numrows($result);

echo '<p>';

//start table
echo "<table class=\"postSchedule\">";
	
	//create table row with column ID's
	echo "<tr>";
		echo "<td><b>Building Name</b></td>";
		echo "<td></td>";
	echo "</tr>";

//loop to walk through and print to screen all entries in buildings table
$row_count = 0;
while ($row = mysql_fetch_assoc($result)) 
{
	$row_count++;
	//store each building name and abbreviation in a scalar
	$building_id=$row["id"];
	$building_name=$row["building_name"];
	$abbreviation=$row["abbreviation"];
	
	//generate table row for each building on each iteration of the loop
	echo "<tr";
	if (($row_count%2) != 0) echo " class=\"zebra_stripe\"";
	echo ">";
		echo "<td width=275>$building_name ($abbreviation)</td>";		//building name cell
		
		echo "<td>";		//cell containing form for update timeslots link/button
			echo "<a href='update_preferences_second.php?iid=$instructor_id&amp;bid=$building_id'>Update Preferences</a>";
		echo "</td>";
	echo "</tr>";
		
}

//end table tag
echo "</table>";

echo '</p>';





?>
<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/bottom.inc.php');
?>